package com.shujia.day08.homework.info;

/*
    商品详细信息类：
    属性：商品编号，商品名称，所属类别，商品数量（大于 0），商品价格（大于 0），
    方法：盘点的方法，描述商品信息。内容包括商品名称，商品数量，商品价格，
 */
public class GoodsInfo {
    private String gId;
    private String gName;
    private GoodsKind goodsKind;
    private int gNumber;
    private double price;

    public GoodsInfo() {
    }

    public GoodsInfo(String gId, String gName, GoodsKind goodsKind, int gNumber, double price) {
        this.gId = gId;
        this.gName = gName;
        this.goodsKind = goodsKind;
        setgNumber(gNumber);
        setPrice(price);
    }

    public String getgId() {
        return gId;
    }

    public void setgId(String gId) {
        this.gId = gId;
    }

    public String getgName() {
        return gName;
    }

    public void setgName(String gName) {
        this.gName = gName;
    }

    public GoodsKind getGoodsKind() {
        return goodsKind;
    }

    public void setGoodsKind(GoodsKind goodsKind) {
        this.goodsKind = goodsKind;
    }

    public int getgNumber() {
        return gNumber;
    }

    public void setgNumber(int gNumber) {
        if (gNumber > 0) {
            this.gNumber = gNumber;
        } else {
            System.out.println("库存数量异常，请联系管理员");
        }
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        if (price > 0) {
            this.price = price;
        } else {
            System.out.println("商品单价异常，请联系管理员");
        }
    }

    public void show() {
        System.out.println("商品名称：" + gName);
        System.out.println("所属类别：" + goodsKind.getkName());
        System.out.println("商品售价：" + price);
        System.out.println("库存数量：" + gNumber);
        System.out.println("商品总价：" + (gNumber * price));
    }
}
